clear
use "C:\Users\tuw013\OneDrive - University of Bergen\Anchoring and bargaining\Results replication package\Data.dta"

//Treatment numbering before the transfer:  1=Baseline 2=Random 3=Bargaining Counterpart 4=Informed Stakeholder 5=Uninformed Stakeholder
//Treatment numbering after the transfer:  1=Baseline 2=Random 3=Uninformed Stakeholder 4=Informed Stakeholder 5=Bargaining Counterpart
replace Treatment=10 if Treatment==3
replace Treatment=3 if Treatment==5
replace Treatment=5 if Treatment==10

set scheme s1mono

gen timeindicator=TimeIHaveReadTheInstructionsCont+TimeContinueComprehensionQuestio

replace Accept=mod(Accept,2)


//adjust anchorcoefficients
//replace Anchor=Anchor-550

//Total number of observations
count

//Table 1 Demographics
sum female Dutch economist age
sum female Dutch economist age if Treatment==1
sum female Dutch economist age if Treatment==2
sum female Dutch economist age if Treatment==3
sum female Dutch economist age if Treatment==4
sum female Dutch economist age if Treatment==5

kwallis female, by(Treatment)
kwallis Dutch, by(Treatment)
kwallis economist, by(Treatment)
kwallis age, by(Treatment)


//Figure 1
scatter Priceasked Anchor if Treatment>1 & Type==1, by(Treatment)

//Table 2
regress Priceasked c.Anchor##i.Treatment producercost if Type==1 & Treatment>1
regress Priceasked c.Anchor##i.Treatment producercost female Dutch economist age if Type==1 & Treatment>1

//Table 3
gen anchordif= abs(Anchor-Priceasked)
sum anchordif if Treatment==2 & Type==1
sum anchordif if Treatment==3 & Type==1
ranksum anchordif if (Treatment==2 | Treatment==3) & Type==1, by(Treatment)

//Table 4
regress Priceasked c.Anchor##i.Treatment producercost if Type==1 & Treatment>1
lincom Anchor+3.Treatment#c.Anchor
lincom Anchor+4.Treatment#c.Anchor
lincom Anchor+5.Treatment#c.Anchor
test Anchor+3.Treatment#c.Anchor=0
test Anchor+4.Treatment#c.Anchor=0
test Anchor+5.Treatment#c.Anchor=0
regress Priceasked c.Anchor##i.Treatment producercost female Dutch economist age if Type==1 & Treatment>1
lincom Anchor+3.Treatment#c.Anchor
lincom Anchor+4.Treatment#c.Anchor
lincom Anchor+5.Treatment#c.Anchor
test Anchor+3.Treatment#c.Anchor=0
test Anchor+4.Treatment#c.Anchor=0
test Anchor+5.Treatment#c.Anchor=0

//Table 5
sum anchordif if Treatment==3 & Type==1
sum anchordif if Treatment==4 & Type==1
sum anchordif if Treatment==5 & Type==1
kwallis anchordif if (Treatment>2 & Treatment<6) & Type==1, by(Treatment)

//Table 6
pwcorr Anchor retailprice if Treatment==2 & Type==1, sig
pwcorr Anchor retailprice if Treatment==3 & Type==1, sig
pwcorr Anchor retailprice if Treatment==4 & Type==1, sig
pwcorr Anchor retailprice if Treatment==5 & Type==1, sig
pwcorr Anchor retailprice if Treatment>2 & Type==1, sig

//Figure 2
graph box Priceasked if Type==1, over(Treatment) horizontal nooutsides
//collapse (mean) meanAccept= Accept (semean) semeanAccept=Accept, by(Treatment)
//gen hi = meanAccept + semeanAccept
//gen lo = meanAccept - semeanAccept
//graph twoway (bar meanAccept Treatment, barw(0.75 0.6))  (rcap hi lo Treatment, lcolor(black)),  ///
//    ylabel(0(0.2)1) xlabel(1 "No Anchor" 2 "Random" 3 "Uninformed" 4 "Interested" 5 "Counterpart") ///
//    legend(off) ytitle("Average Acceptance Share") name(barmeans, replace) ///
//	xtitle("")


//Table 7
mean Priceasked, over(Treatment)
kwallis Priceasked if Type==1, by(Treatment)
mean Accept, over(Treatment)
kwallis Accept if Type==1, by(Treatment)
gen producerprofitpoints=0
replace producerprofitpoints=Priceasked-producercost if Accept==1
mean producerprofitpoints, over(Treatment)
kwallis producerprofitpoints if Type==1, by(Treatment)
gen retailerprofitpoints=0
replace retailerprofitpoints=(retailprice-Priceasked)/2 if Accept==1
mean retailerprofitpoints, over(Treatment)
kwallis retailerprofitpoints if Type==1, by(Treatment)

//Table 8
reg qanswer1 questionanchor1
pwcorr qanswer1 questionanchor1, sig
reg qanswer2 questionanchor2
pwcorr qanswer2 questionanchor2, sig
reg qanswer3 questionanchor3
pwcorr qanswer3 questionanchor3, sig

//expand(3)
//gen counter=_n
//gen qanswer=.
//replace qanswer=qanswer1 if counter<463
//replace qanswer=qanswer2 if counter>462 & counter<462*2+1
//replace qanswer=qanswer3 if counter>462*2

//gen questionanchor=.
//replace questionanchor=questionanchor1 if counter<463
//replace questionanchor=questionanchor2 if counter>462 & counter<462*2+1
//replace questionanchor=questionanchor3 if counter>462*2

//gen trueanswer=.
//replace trueanswer=280 if counter<463
//replace trueanswer=604 if counter>462 & counter<462*2+1
//replace trueanswer=106 if counter>462*2

//reg qanswer questionanchor trueanswer, cluster(ID)
//reg qanswer questionanchor trueanswer if Type==1, cluster(ID)
//reg qanswer questionanchor, cluster(ID)
//reg qanswer questionanchor if Type==1, cluster(ID)


//Figure 3
hist anchorcoefficients if Type==1 & Treatment>1 & abs(anchorcoefficients)<30, width(1) frequency xlabel(-30(5)30)
hist anchorcoefficients if Type==1 & Treatment>1 & abs(anchorcoefficients)<5, width(0.15) frequency xlabel(-5(1)5)

//Table 9
regress Priceasked c.Anchor##c.anchorcoefficients producercost if Type==1 & Treatment>1 & abs(anchorcoefficients)<5
regress Priceasked c.Anchor##c.anchorcoefficients female Dutch economist producercost if Type==1 & Treatment>1 & abs(anchorcoefficients)<5

//Table 10
keep if Type==1 & Treatment>1
egen anchoreffectrank=rank(anchorcoefficients)
egen maxrank=max(anchoreffectrank)
egen minrank=min(anchoreffectrank)
replace anchoreffectrank=((anchoreffectrank-1)/122)-0.5

regress Priceasked c.Anchor##c.anchoreffectrank producercost  if Type==1 & Treatment>1
regress Priceasked c.Anchor##c.anchoreffectrank female Dutch economist producercost if Type==1 & Treatment>1